/* GUI CONVERTED from rsshmtt.i (converter v1.76) Thu Apr 11 05:26:29 2002 */
/* rsshmtt.i - Supplier Shippers Tolerance Checking                     */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                  */
/* All rights reserved worldwide.  This is an unpublished work.         */
/* $Revision: 1.4.1.5 $                                                         */
/*V8:ConvertMode=Maintenance                                   */
/* REVISION: 7.3    LAST MODIFIED: 05/29/96           BY: vrn *G1NV*    */
/* REVISION: 8.6    LAST MODIFIED: 05/20/98           BY: *K1Q4* Alfred Tan */
/* REVISION: 8.6E   LAST MODIFIED: 06/24/98           BY: *L020* Charles Yen */
/* REVISION: 9.0    LAST MODIFIED: 03/29/99           BY: *J3BM* Reetu Kapoor*/
/* $Revision: 1.4.1.5 $    BY: Jean Miller           DATE: 04/09/02  ECO: *P058*  */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/
/* REVISION: 9.1    LAST MODIFIED: 08/12/00           BY: *N0KP* myb         */

/** TO IMPROVE PERFORMANCE   **/

for each work_abs_mstr
      where abs_order > "" no-lock,

      each pod_det
      fields (pod_line pod_nbr pod_pur_cost pod_qty_ord
      pod_qty_rcvd pod_sched pod_um_conv) no-lock
      where pod_nbr  = abs_order
      and   pod_line = integer(abs_line),

      each po_mstr
      fields (po_curr po_ex_rate po_ex_rate2 po_fix_rate po_nbr) no-lock
      where po_nbr = pod_nbr
      break by pod_nbr by pod_line:
/*GUI*/ if global-beam-me-up then undo, leave.


   qty_to_rcv = abs_qty - abs_ship_qty.
   accumulate qty_to_rcv(sub-total by pod_line).
   if work_abs_mstr.abs_par_id <> abs_mstr.abs_id then
      warn_substruct = yes.

   if last-of(pod_line) then do:

      assign
         total_received = ((accum sub-total by pod_line qty_to_rcv)
         / pod_um_conv) + pod_qty_rcvd
         base_amt = pod_pur_cost.

      if po_fix_rate = no then do:
         {gprunp.i "mcpl" "p" "mc-get-ex-rate"
            "(input po_curr,
              input base_curr,
              input "" "",
              input today,
              output exch_rate,
              output exch_rate2,
              output mc-error-number)"}
         if mc-error-number <> 0 then do:
            {pxmsg.i &MSGNUM=mc-error-number &ERRORLEVEL=3}
            /* EXCHANGE RATE DOES NOT EXIST */
         end.
      end.
      else
      assign  exch_rate = po_ex_rate
         exch_rate2 = po_ex_rate2.

      {gprunp.i "mcpl" "p" "mc-curr-conv"
         "(input po_curr,
           input base_curr,
           input exch_rate,
           input exch_rate2,
           input base_amt,
           input false, /* DO NOT ROUND */
           output base_amt,
           output mc-error-number)"}

      if warn_substruct and (pod_sched or (not pod_sched and
         (total_received > pod_qty_ord and pod_qty_ord > 0) or
         (total_received < pod_qty_ord and pod_qty_ord < 0)))
      then do:
         /* Receipt tolerance checking and max order qty */
         {gprun.i ""rsporct.p""
            "(input (accum sub-total by pod_line qty_to_rcv),
              input recid(po_mstr),
              input recid(pod_det),
              input today,
              input poc_tol_pct,
              input poc_tol_cst,
              input base_amt ,
              input yes,
              input yes,
              output dummy_logi)"}
/*GUI*/ if global-beam-me-up then undo, leave.

      end.
      warn_substruct = no.
   end. /* if last-of(pod_line)  */

end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /* for each work_abs_mstr  */
